<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/amazeui.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/myplugs/js/plugs.js"></script>
    <script src="${pageContext.request.contextPath}/js/layui.js"></script>
    <script>
        function insertHospital(title, id) {
            $.jq_Panel({
                title: title,
                iframeWidth: 500,
                iframeHeight: 400,
                url: "/hospital/insertHospital"
            });
        }
        function updateHospital(title,id) {
            console.log("hospital_id:"+id)
            $.jq_Panel({
                title: title,
                iframeWidth: 500,
                iframeHeight: 420,
                url: "/hospital/updateHospital?id="+id
            });
        }
        function deleteHospital(id){
            var datas={};
            datas.id=id;
            var r= confirm("确认删除？");
            if (r==true) {
                $.ajax({
                    async: false,
                    type: "POST",
                    url: "/hospital/deleteHospital",//注意路径
                    data: datas,
                    dataType: "json",
                    success: function (data) {
                        if (data.result == 'SUCCESS') {
                            alert("删除成功！");
                            window.location.reload();
                        } else {
                            alert("删除失败，失败原因【" + data.result + "】");
                        }
                    },
                    error: function (data) {
                        alert(data.result);
                    }
                });
                return true;
            }
            else {
                return false;
            }


        }
    </script>
</head>
<body>
<div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">医院浏览</strong><small></small></div>
    </div>

    <hr>

    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <button type="button" class="am-btn am-btn-default"  onclick="insertHospital('新增医院',1)"><span class="am-icon-plus"></span> 新增</button>
                </div>
            </div>
        </div>
        <div class="am-u-sm-12 am-u-md-3">

        </div>
<%--        <div class="am-u-sm-12 am-u-md-3">--%>
<%--            <div class="am-input-group am-input-group-sm">--%>
<%--                <input type="text" class="am-form-field" placeholder="请输入留言信息">--%>
<%--                <span class="am-input-group-btn">--%>
<%--            <button class="am-btn am-btn-default" type="button">搜索</button>--%>
<%--          </span>--%>
<%--            </div>--%>
<%--        </div>--%>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12">
            <form class="am-form">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                    <tr>
                        <th class="table-id" style="width: 30px">ID</th>
                        <th class="table-title" style="width: 240px">店名</th>
                        <th class="table-type" style="width:70px">类型</th>
                        <th class="table-author am-hide-sm-only" style="width: 57px">地区</th>
                        <th class="table-date am-hide-sm-only" style="width:206px">详细地址</th>
                        <th class="table-author" style="width: 44px">评分</th>
                        <th class="table-author" style="width: 73px">评价人数</th>
                        <th class="table-author" style="width: 73px">人均消费</th>
                        <th class="table-author" style="width: 44px">总分</th>
                        <th class="table-author" style="width: 44px">环境</th>
                        <th class="table-author" style="width: 44px">服务</th>
                        <th class="table-author" style="width: 110px">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${hospitalPageInfo.list}" var="f">
                        <tr>
                            <td>${f.id}</td>
                            <td>${f.name}</td>
                            <td>${f.type}</td>
                            <td class="am-hide-sm-only">${f.area}</td>
                            <td class="am-hide-sm-only">${f.address}</td>
                            <td>${f.point}</td>
                            <td>${f.pointNum}</td>
                            <td>${f.average}</td>
                            <td>${f.zongfen}</td>
                            <td>${f.huanjing}</td>
                            <td>${f.fuwu}</td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="updateHospital( '修改医院信息','${f.id}')"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                        <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="return deleteHospital(${f.id})"><span class="am-icon-trash-o" ></span> 删除</button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <div class="am-cf">
                    共 ${hospitalPageInfo.total} 条记录
                    <div class="am-fr">
                        <ul class="am-pagination">
                            <li>
                                <a href="/hospital/hospitalInfo?pageNum=1">首页</a>
                            </li>
                            <li class="am-active">
                                <a href="/hospital/hospitalInfo?pageNum=${hospitalPageInfo.prePage}">«</a>
                            </li>
                            <li class="am-active">
                                <a href="/hospital/hospitalInfo?pageNum=${hospitalPageInfo.pageNum}">${hospitalPageInfo.pageNum}</a>
                            </li>
                            <li>
                                <a href="/hospital/hospitalInfo?pageNum=${hospitalPageInfo.nextPage}">»</a>
                            </li>
                            <li>
                                <a href="/hospital/hospitalInfo?pageNum=${hospitalPageInfo.pages}">${hospitalPageInfo.pages}</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <hr>
            </form>
        </div>

    </div>
</div>
</body>
</html>
